--**** NASS COMPACTER by Brian D. McLean, D.D.S. ****
--
-- uses the XFCN Files() by
on packem
--IF YOU PASTE THIS SCRIPT ELSEWHERE THEN DELETE ALL
-- THESE LINES IN UPPER CASE.
GLOBAL EXAMINED,COMPACTED,SAVED,ABORT
PUT TRUE INTO ABORT
-- IF YOU PASTE THIS STACK ELSEWHERE THEN DELETE ALL THE UPPER CASE
-- LINES.
global compacterPath
ask "Compact stacks in what directory (complete path)" with compacterPath
if it is not empty then
put it into compacterPath
Put Files(it,"STAK") into stacknames
else
exit packem
end if
push card
--IF YOU PASTE THIS SCRIPT ELSEWHERE THEN DELETE ALL
-- THESE LINES IN UPPER CASE.
PUT FALSE INTO ABORT
-- IF YOU PASTE THIS STACK ELSEWHERE THEN DELETE ALL THE UPPER CASE
-- LINES.
put zero into examined
put zero into compacted
put zero into saved
repeat with x = 1 to number of lines of stacknames
put line x of stacknames into thisstack
put "Checking " & quote & thisstack & quote
get the freesize of stack thisstack
add it to saved
add one to examined
put " -- Freesize is"&&it after msg
if it is zero then
wait 30
else
set lockmessages to true
set lockscreen to true
go to stack thisstack
put "Compacting" into first word of msg
domenu "compact stack"
add one to compacted
end if
end repeat
pop card
--IF YOU PASTE THIS SCRIPT ELSEWHRE THEN DELETE THE TWO DASHES “--”
--IN THE FOLLOWING 3 LINES...
Put "All done!" -- && "Examined" && examined && "stacks; compacted" -- && compacted &&"to regain" && saved && "bytes."
-- wait 3 seconds
hide msg
end packem
-- part 4 (field)
-- low flags: 01
-- high flags: 2001
-- rect: left=41 top=64 right=289 bottom=389
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 9
-- style flags: 0
-- line height: 12
-- part name:
-- part 10 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=410 top=137 right=155 bottom=480
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Packem
----- HyperTalk script -----
on mouseUp
global examined,compacted,saved,compacterpath,abort
if the short name of the target is "Return" then
set the name of the target to "Packem"
hide card field "results"
else if the short name of the target is "Packem" then
packem
if abort is true then exit mouseup
put empty into card field "results"
put "Result of Stack Compaction in" into line 4 of card field "results"
put compacterpath & return & the abbr date && the time into line 5 of card field "results"
put "Number of stacks examined:" && examined into line 9 of card field "results"
put "Number of stacks compacted:" && compacted into line 11 of card field "results"
put "Number of bytes reclaimed:" &&saved into line 13 of card field "results"
set the name of the target to "Return"
show card field "results"
end if
end mouseUp
-- part 11 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=410 top=178 right=196 bottom=480
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Script
----- HyperTalk script -----
on mouseUp
edit script of this card
end mouseUp
-- part 17 (button)
-- low flags: 00
-- high flags: 0000
-- rect: left=451 top=286 right=313 bottom=486
-- title width / last selected line: 0
-- icon id / first selected line: 11045 / 11045
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Home
----- HyperTalk script -----
on mouseUp
visual effect dissolve to black
visual effect dissolve to white
visual effect dissolve
go home
end mouseUp
-- part 2 (field)
-- low flags: 81
-- high flags: 0004
-- rect: left=437 top=48 right=316 bottom=488
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 18
-- style flags: 6144
-- line height: 24
-- part name: info title
-- part 3 (button)
-- low flags: 00
-- high flags: 0000
-- rect: left=446 top=35 right=61 bottom=477
-- title width / last selected line: 0
-- icon id / first selected line: 19678 / 19678
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name:
----- HyperTalk script -----
on mouseUp
set the scroll of card field "info" to zero
set visible of Card field "info" to not visible of card field "info"
set visible of Card field "info title" to not visible of card field "info title"
end mouseUp
-- part 6 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=204 top=280 right=315 bottom=379
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 9
-- style flags: 256
-- line height: 12
-- part name:
-- part 18 (field)
-- low flags: 81
-- high flags: 2004
-- rect: left=102 top=85 right=214 bottom=338
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 9
-- style flags: 0
-- line height: 12
-- part name: note
----- HyperTalk script -----
on mouseup
hide card field note
end mouseup
-- part 1 (field)
-- low flags: 81
-- high flags: 2007
-- rect: left=17 top=28 right=320 bottom=437
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: info
-- part 7 (field)
-- low flags: 80
-- high flags: 0004
-- rect: left=36 top=59 right=321 bottom=393
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: Results
-- part 19 (button)
-- low flags: 00
-- high flags: 2000
-- rect: left=127 top=235 right=250 bottom=141
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name:
----- HyperTalk script -----
on mouseUp
show card field "note"
end mouseUp
-- part contents for card part 1
----- text -----
Files() is a XFCN to get a list of files in a HFS directory.
You can specify the path name to the files and the file type you want to retreive.
This is freeware!
Guy de Picciotto.
CIS: 73300,3637
GENIE: G.PICCIOTO
Files() can take 2 parameters:
The first one is the path name to look for files. If it does not exist or is empty, the default directory is used (I hope so)
The second parameter is the file type. You can look for multiple types. If no second parameter is supplied, files will return all files.
In case of an error, the routine will beep and return an empty string.
Ex. get Files("mydisk:hypercard","STAK,TXT")
get Files("mydisk:hypercard")
get Files("","STAK")
get Files()
(CLick “About” baloon to return)
-- part contents for card part 4
----- text -----
The button to the right evokes the script (“Packem”) of this card.
A dialog box requests a full pathname to a desktop or folder.
“Packem” then proceeds to examine the freesize (wasted space) in all the stacks it finds there. If any stacks need compacting, then that is accomplished automatically. In the meantime, you are free to get a cup of coffee.
Progress is displayed via the message box, and a summary of the results is posted upon completion.
Suggestion: Paste the card script into your home stack, and use this utility wherever and whenever it is convenient by typing “Packem” into the message box.(*)
Click the “About Files() XFCN” balloon for information about the XFCN which makes all this possible.
-- part contents for card part 2
----- text -----
F i l e s ()
X F C N
-- part contents for card part 6
----- text -----
Brian D. Mclean
CIS 75026,3724
GEnie B.McLean
-- part contents for card part 18
----- text -----
*SPECIAL NOTE*
This has the advantage of overcoming one dumb feature of this demonstration stack:
After “Packem” has compacted this stack, the button name changes to ‘Return’ and then back to ‘Packem’, which means the stack is no longer fully compacted. But then again, its ready for another demonstration!